Skip to content

Conversation

@echapmanFromBunnings
Copy link

@echapmanFromBunnings echapmanFromBunnings commented Nov 18, 2025

Introduces a Headers property to HostedMcpServerTool for specifying additional request headers. Updates OpenAIResponsesChatClient to pass these headers when creating MCP tools and adds unit tests to verify header roundtripping.

Microsoft Reviewers: Open in CodeFlow

Introduces a Headers property to HostedMcpServerTool for specifying additional request headers. Updates OpenAIResponsesChatClient to pass these headers when creating MCP tools and adds unit tests to verify header roundtripping.
Copilot AI review requested due to automatic review settings November 18, 2025 15:13
@echapmanFromBunnings echapmanFromBunnings requested a review from a team as a code owner November 18, 2025 15:13
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Nov 18, 2025
Copilot finished reviewing on behalf of echapmanFromBunnings November 18, 2025 15:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for custom HTTP headers in HostedMcpServerTool, enabling users to specify additional request headers when communicating with remote MCP servers.

  • Introduces a Headers property of type IDictionary<string, string>? to the HostedMcpServerTool class
  • Updates OpenAIResponsesChatClient to pass these headers to both variants of ResponseTool.CreateMcpTool()
  • Adds roundtrip tests to verify the Headers property can be set, retrieved, and cleared

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs Adds the nullable Headers property with XML documentation
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Passes mcpTool.Headers parameter to both CreateMcpTool overloads (URI-based and connector ID-based)
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/HostedMcpServerToolTests.cs Adds assertions to verify Headers can be set to a dictionary, retrieved, and reset to null

@echapmanFromBunnings
Copy link
Author

@stephentoub any chance I can get an assignee on this one to help with getting it through? This is #7049 with the reverts.

@stephentoub stephentoub requested a review from jozkee November 25, 2025 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant